/**
* @file Decoder.h in InsCubeDecoder
* @author rebeater
* @comment InsCube 原始文件解码程序
* Create on 2/22/22 11:03 AM
* @version 1.0
**/

#ifndef INSCUBEDECODER__DECODER_H_
#define INSCUBEDECODER__DECODER_H_
#include <vector>
#include <fstream>
#include <memory>
#include "RawStruct.h"
#include "NavStruct.h"

#include "AdiHandle.h"
#include "RstHandle.h"
namespace InsCube {
enum RawFileType {
  MIX,
  GNSS,
  CPT,
  RST
};
enum FileType {
  ImuTxt,
  Imd,
  GnssTxt,
  VelTxt,
  BmpTxt,
  RstTxt,
};

template<RawFileType T1,class H>
class BaseDecoder {
 private:
  H handle;
  void *p_data = nullptr;
  uint32_t data_cnt{0};
 protected:
  explicit BaseDecoder(const H &handle);
  BaseDecoder();
  template<FileType T2>
  void SaveTo(const std::string &outpath);
 public:
  void Load(const std::string &raw_path);
 uint32_t GetSize() const { return data_cnt;};
  ~BaseDecoder();
};

//template<>
//template<>
class RawDecoder : public BaseDecoder<MIX,ADIHandleBase> {
 private:
 public:
 explicit RawDecoder(const ADIHandleBase &handle) ;
  void SaveToImu(const std::string &outpath);
  void SaveToImd(const std::string &outpath);
  void SaveToGnss(const std::string &outpath);
  void SaveToVel(const std::string &outpath);
  void SaveToRst(const std::string &outpath);
  void SaveToBmp(const std::string &outpath);
  ~RawDecoder();
};
class CptDecoder:public BaseDecoder<CPT,CptHandle>{
 public:
  explicit CptDecoder();
  ~CptDecoder();
  void SaveToImuTxt(const std::string &outpath);
};
class RstDecoder: public BaseDecoder<RST, RstHandle>{
 public:
  explicit RstDecoder();
  void SaveToRstTxt(const std::string &outpath);
  ~RstDecoder();
};
}
#endif //INSCUBEDECODER__DECODER_H_
